
//
//  BarberDetailsTableViewCell.m
//  afn
//
//  Created by mac on 2018/5/9.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "BarberDetailsTableViewCell.h"

@implementation BarberDetailsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(CGFloat)creawtView1{
    BarberMsgModel *model=[BarberMsgModel mj_objectWithKeyValues:_model.barber_msg];
    
    self.backgroundColor=_LightGrey;
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-7);
    }];
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIImageView *imageView=[UIImageView new];
    [beiJingView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(90);
    }];
    NSString *url=model.pic_url;
    [imageView sd_setImageWithURL:[NSURL URLWithString:url]];
    imageView.layer.cornerRadius=45;
    imageView.layer.masksToBounds=YES;
    
    UILabel *nameLabel=[UILabel new];
    [beiJingView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(10);
        make.top.mas_equalTo(imageView);
        make.right.mas_equalTo(-10);
    }];
    nameLabel.text=model.barber_name;
    nameLabel.font=[UIFont systemFontOfSize:17];
    nameLabel.textColor=ColorWithRGB(29, 29, 29);
    
    CGSize size=[gongju getNSStringWeight:model.position andViewWight:20 andFont:13];
    UILabel *zhiWeiLabel=[UILabel new];
    [beiJingView addSubview:zhiWeiLabel];
    [zhiWeiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.centerY.mas_equalTo(imageView);
        make.height.mas_equalTo(25);
        make.width.mas_equalTo(size.width+10);
    }];
    zhiWeiLabel.textColor=_backgroundColor;
    zhiWeiLabel.layer.cornerRadius=2;
    zhiWeiLabel.layer.borderColor=_backgroundColor.CGColor;
    zhiWeiLabel.layer.borderWidth=1;
    zhiWeiLabel.text=model.position;
    zhiWeiLabel.font=[UIFont systemFontOfSize:12];
    zhiWeiLabel.textAlignment=NSTextAlignmentCenter;
    
    UILabel *timeLabel=[UILabel new];
    [beiJingView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(zhiWeiLabel.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(imageView);
    }];
    timeLabel.textColor=ColorWithRGB(29, 29, 29);
    timeLabel.font=[UIFont systemFontOfSize:15];
    timeLabel.text=[NSString stringWithFormat:@"%@年",model.work_years];
    
    UILabel *shanChangLabel=[UILabel new];
    [beiJingView addSubview:shanChangLabel];
    [shanChangLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel);
        make.top.mas_equalTo(imageView.mas_bottom).mas_equalTo(-15);
        make.right.mas_equalTo(-10);
    }];
    NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"擅长：%@",model.keywords]];
    [attributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(29, 29, 29) range:NSMakeRange(0, 3)];
    [attributedStr addAttribute:NSForegroundColorAttributeName value:ColorWithRGB(149, 149, 149) range:NSMakeRange(3, model.keywords.length)];
    shanChangLabel.attributedText=attributedStr;
    shanChangLabel.font=[UIFont systemFontOfSize:14];
    shanChangLabel.numberOfLines=3;
    
    UIView *XianView= [UIView new];
    [beiJingView addSubview:XianView];
    [XianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(1);
        make.top.mas_equalTo(shanChangLabel.mas_bottom).mas_equalTo(10);
    }];
    XianView.backgroundColor=_LightGrey;
    
    UILabel *jianJieLabel=[UILabel new];
    [beiJingView addSubview:jianJieLabel];
    [jianJieLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(XianView.mas_bottom).mas_equalTo(7);
    }];
    jianJieLabel.text=@"简介：";
    jianJieLabel.textColor=ColorWithRGB(29, 29, 29);
    jianJieLabel.font=[UIFont systemFontOfSize:14];
    
    UILabel *label2=[UILabel new];
    [beiJingView addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(jianJieLabel.mas_right).mas_equalTo(3);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(jianJieLabel);
    }];
    label2.text=model.barber_detail;
    label2.font=[UIFont systemFontOfSize:14];
    label2.textColor=ColorWithRGB(149, 149, 149);
    label2.numberOfLines=0;
    [label2 layoutIfNeeded];
    [shanChangLabel layoutIfNeeded];
    
    return 130+shanChangLabel.frame.size.height+label2.frame.size.height;
}
-(void)creawtView2{
    BarberMsgModel *model=[BarberMsgModel mj_objectWithKeyValues:_model.barber_msg];
    self.backgroundColor=_LightGrey;
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-7);
    }];
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIView *bottomView=[UIView new];
    [beiJingView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(70);
    }];
    
    UIImageView *weiZhi=[UIImageView new];
    [bottomView addSubview:weiZhi];
    [weiZhi mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(15);
    }];
    weiZhi.image=[UIImage imageNamed:@"ico-map"];
    
    UILabel *addLabel=[UILabel new];
    [bottomView addSubview:addLabel];
    [addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weiZhi.mas_right).mas_equalTo(6);
        make.bottom.mas_equalTo(weiZhi.mas_centerY).mas_equalTo(-3);
        make.right.mas_equalTo(-70);
    }];
    addLabel.text=model.address;
    addLabel.textColor=ColorWithRGB(49, 49, 49);
    addLabel.font=[UIFont systemFontOfSize:14];
    
    UILabel *juLiLabel=[UILabel new];
    [bottomView addSubview:juLiLabel];
    [juLiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(addLabel);
        make.right.mas_equalTo(addLabel);
        make.top.mas_equalTo(weiZhi.mas_centerY).mas_equalTo(3);
    }];
    juLiLabel.text=@"距离您45KM";
    juLiLabel.textColor=ColorWithRGB(149, 149, 149);
    juLiLabel.font=[UIFont systemFontOfSize:12];
    
    
    
    UIButton *phoneBtn=[UIButton new];
    [bottomView addSubview:phoneBtn];
    [phoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(weiZhi);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(50);
    }];
    [phoneBtn setImage:[UIImage imageNamed:@"ico-dianhua"] forState:0];
    
    UIView *xianView=[UIView new];
    [bottomView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(phoneBtn.mas_left).mas_equalTo(-8);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    

    
    UIView *topView=[UIView new];
    [beiJingView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(40);
    }];
    
    UILabel *nameLabel=[UILabel new];
    [topView addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(addLabel);
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    nameLabel.text=model.shop_name;
    nameLabel.textColor=ColorWithRGB(29, 29, 29);
    nameLabel.font=[UIFont systemFontOfSize:16];
    
}
-(CGFloat)creatView3{
    

    self.backgroundColor=_LightGrey;
    UIView *beiJingView=[UIView new];
    [self addSubview:beiJingView];
    [beiJingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-7);
    }];
    beiJingView.backgroundColor=[UIColor whiteColor];
    
    UIView *topView=[UIView new];
    [beiJingView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.mas_equalTo(30);
    }];
    
    UILabel *label=[UILabel new];
    [topView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    label.textColor=ColorWithRGB(29, 29, 29);
    label.text=@"服务详情";
    label.font=[UIFont systemFontOfSize:16];
    
    for (int i=0 ; i<_model.barber_msg_node.count; i++) {
        BarberMsgNodeModel *model=[BarberMsgNodeModel mj_objectWithKeyValues:_model.barber_msg_node[i]];
        
        UIView *fuWuView=[UIView new];
        [beiJingView addSubview:fuWuView];
        [fuWuView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(40);
            make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(40*i);
        }];
        
        UIImageView *imageView=[UIImageView new];
        [fuWuView addSubview:imageView];
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(10);
            make.centerY.mas_equalTo(0);
            make.width.height.mas_equalTo(30);
        }];
        NSString *url=model.pic_url;
        [imageView sd_setImageWithURL:[NSURL URLWithString:url]];
        
        UILabel *label2=[UILabel new];
        [fuWuView addSubview:label2];
        [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(imageView.mas_right).mas_equalTo(10);
            make.right.mas_equalTo(-100);
            make.centerY.mas_equalTo(0);
        }];
        label2.text=model.hairdresser_name;
        label2.font=[UIFont systemFontOfSize:14];
        label2.textColor=ColorWithRGB(49, 49, 49);
        
        UILabel *priceLabel=[UILabel new];
        [fuWuView addSubview:priceLabel];
        [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-10);
            make.centerY.mas_equalTo(0);
        }];
        
        priceLabel.text=[NSString stringWithFormat:@"¥%@",model.favorable_Price];
        priceLabel.textColor=ColorWithRGB(49, 49, 49);
        priceLabel.font=[UIFont systemFontOfSize:14];
    }
    
    
    
    return 40*(_model.barber_msg_node.count+1);
}
@end
